/*
 * @Author: 肖思汗
 * @Date: 2021-02-26 23:33:07
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2021-11-07 14:57:20
 */

import * as THREE from "three";
import { RawShaderMaterial, ShaderMaterial } from "three";
import Material from "../mixin/Material";
import { THREEMouseEvent } from "../Renderer/THREEMouse";

export default class Object3D extends THREE.Object3D<THREE.Event> {

    constructor() {
        super();
    }

    material!: Material | ShaderMaterial | RawShaderMaterial | THREE.Material;

    matrixWorldNeedsUpdate: boolean = false;

    matrixAutoUpdate: boolean = false;

    declare parent: Object3D;

    // 子元素
    children: Object3D[] = [];

    // 鼠标样式
    cursor?: string;

    isGroup?: boolean; // 是否是组对象

    onMousemove?: (e: THREEMouseEvent) => void;

    onMouseleave?: (e: THREEMouseEvent) => void;

    onMouseenter?: (e: THREEMouseEvent) => void;

    onMousedown?: (e: THREEMouseEvent) => void;

    onMouseup?: (e: THREEMouseEvent) => void;

    onClick?: (e: THREEMouseEvent) => void;

    // 开启裁剪
    clipping?: boolean = true;

    clipPlanes?: THREE.Plane[]; // 裁剪面数组

    geometry!: THREE.BufferGeometry;

    // 添加裁剪面
    addClipPlane(plane: THREE.Plane): this { return this; };

    // 移除裁剪面
    removeClipPlane(plane: THREE.Plane): this { return this };

    add(...object: THREE.Object3D<THREE.Event>[]): this { return this };
}